package com.fosu.dao;

import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @ClassName FeedbackImgDao
 * @Description 反馈意见与图片持久层
 * @Author 夜天冥
 * @Date 2020/11/14 20:33
 * @Version 1.0
 */
@Mapper
@Repository
public interface FeedbackImgDao {
    /**
     * @Author 夜天冥
     * @Description //根据反馈id获得图片组 * @Date  2020/11/14
     * @Param feedbackId
     * @return List<String> 图片组的url字串集合
     **/
    @Select("select img_url" +
            "from feedback_imgs" +
            "where feedback_id=#{feedbackId}")
    @Results(id = "img", value = {
            @Result(property = "imgUrl", column = "img_url")
    })
    List<String> findImgsById(int feedbackId);

    /**
     * @Author 夜天冥
     * @Description //插入图片url  * @Date  2020/11/14
     * @Param feedbackId 反馈id
     * @param imgUrl 要插入图片的url
     **/
    @Insert("insert into feedback_imgs(feedback_id,img_url) values(#{feedbackId},#{imgUrl})")
    @Results(id = "imgMap", value = {
            @Result(property = "feedbackId", column = "feedback_id"),
            @Result(property = "imgUrl", column = "img_url")
    })
    void save(int feedbackId, String imgUrl);
}
